package beautiful.butterfly.drds.data_exchange.transport.record.column.column_cast;

import beautiful.butterfly.drds.data_exchange.transport.record.column.BytesColumn;
import beautiful.butterfly.drds.data_exchange.transport.record.column.DateColumn;
import beautiful.butterfly.drds.data_exchange.transport.record.column.StringColumn;
import beautiful.butterfly.drds.data_exchange.util.Configuration;

import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.Date;

public final class ColumnCast
{

    public static void bind(final Configuration configuration)
    {
        StringCast.init(configuration);
        DateCast.init(configuration);
        BytesCast.init(configuration);
    }

    public static Date string2Date(final StringColumn column)
            throws ParseException
    {
        return StringCast.asDate(column);
    }

    public static byte[] string2Bytes(final StringColumn column)
            throws UnsupportedEncodingException
    {
        return StringCast.asBytes(column);
    }

    public static String date2String(final DateColumn column)
    {
        return DateCast.asString(column);
    }

    public static String bytes2String(final BytesColumn column)
            throws UnsupportedEncodingException
    {
        return BytesCast.asString(column);
    }
}

